<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-7-21
 * Func   个人报表
 */
defined('IN_YuLin') || exit('NO PERMIT!');

UserLogin(U($m.'/'.$c.'/'.$a));

$table = Table('user_money_count');

$data  = [];
$where = ' FROM '.$table.' t WHERE t.uid = '.$_uid;

$dt = NoBadStr($_GET['dtrange']);
$dt = explode(' - ',$dt);
!$dt[0] && $dt[0] = date('Y-m-d',strtotime('-1 day'));
!$dt[1] && $dt[1] = date('Y-m-d');
$dtrange = implode(' - ',$dt);

$where .= ' AND t.dateline >= '.strtotime($dt[0]).' AND t.dateline < '.(strtotime($dt[1]) + 86400);

$page = max(1,intval($_GET['page']));
$size = max(100,intval($_GET['size']));

$tmp = $db->getrow('SELECT COUNT(1) AS p '.$where);
if($tmp['p'])
{
	$orderby = ' ORDER BY t.id DESC ';
	$limit = ' LIMIT '.($page - 1) * $size.','.$size;
	
	$data = $db->getall('SELECT t.* '.$where.$orderby.$limit);
}

$head['title'] = '个人报表';

$tpl->display('member/moneycount');